package com.huage_08.lesson_04;

import java.io.IOException;
import java.net.*;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        //创建Socket对象
        DatagramSocket ds = new DatagramSocket();

        //打包数据
        byte[] bytes = "Hello World! 你好".getBytes();
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length, InetAddress.getByName("192.168.56.1"),1997);

        //发送数据
        ds.send(dp);

        //关闭Socket
        ds.close();
    }
}
